package com.yugao.fintech.antelope.infra.weixin.mp.assembly;

import com.yugao.fintech.antelope.infra.weixin.mp.model.entity.MpMaterial;
import com.yugao.fintech.antelope.infra.weixin.mp.model.rqrs.MpMaterialResp;
import com.yugao.fintech.antelope.infra.weixin.mp.model.rqrs.MpMaterialUpdateReq;
import me.chanjar.weixin.mp.bean.material.WxMpMaterial;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.io.File;

/**
 * 公众号素材
 *
 
 */
@Mapper(componentModel = "spring")
public interface MpMaterialAssembly {
    MpMaterialResp toMpMaterialResp(MpMaterial source);

    MpMaterial toMpMaterial(MpMaterialUpdateReq source);

    default WxMpMaterial toWxMpMaterial(String name, File file, String title, String introduction) {
        return new WxMpMaterial(name, file, title, introduction);
    }

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(source = "name", target = "name"),
            @Mapping(source = "filePath", target = "url"),
            @Mapping(source = "mpUrl", target = "mpUrl"),
    })
    MpMaterial toMpMaterial(String mediaId, String type, String filePath, String name, String title,
                            String introduction, String mpUrl);
}
